package com.ehotting.edsta.system.controller;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.spring.cloud.service.NacosConfigService;
import com.ehotting.edsta.system.domain.dto.OperCountDto;
import com.ehotting.edsta.system.domain.vo.AccessCountVo;
import com.ehotting.edsta.system.service.IHomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 后台首页统计controller
 */
@Api(tags = "HomeController",description = "后台首页统计controller")
@RestController
@RequestMapping("/home")
public class HomeController {

    @Resource
    private IHomeService homeService;


    /**
     * 统计成功登录次数
     * @param timeType 时间标志  0:过去7天, 1:过去30天, 2:过去365天
     * @return 结果
     */
    @ApiOperation("统计成功登录次数")
    @GetMapping("/accessCount")
    public R<AccessCountVo> accessCount(Integer timeType){
        return R.ok(homeService.accessCount(timeType));
    }

    /**
     * 统计功能操作次数
     *
     * @param timeType 时间标志  0:过去7天, 1:过去30天, 2:过去365天
     * @return 结果
     */
    @ApiOperation("统计成功登录次数")
    @GetMapping("/operCount")
    public R<List<OperCountDto>> operCount(Integer timeType){
        return R.ok(homeService.operCount(timeType));
    }


}
